//索引泛型类型
interface ObjectAny {
  [key: string]: any
}
let obj1: ObjectAny = {
  name: 'aaa',
  id: 123,
  hobby: ['a', 'b', 'c']
}
console.log(obj1);
console.log(obj1.name);
console.log(obj1['name']);
//模拟数组实现
interface MyArry<T> {
  [key: number]: T
}

let array: MyArry<number> = [1, 2, 3, 4]
console.log(array);
//映射类型
//对于类型全部一致的处理
type PropKeys = 'x' | 'y' | 'z'
type Type1 = { x: number, y: number, z: number }
type Type2 = { [key in PropKeys]: number }
let type2: Type2 = {
  x: 1,
  y: 2,
  z: 3
}
console.log(type2);
//对于类型不全部一致的处理
//利用Partical处理  但是参数都变为可选参数
type Props3 = { x: number, y: boolean, z: string }
type ParticalProps3 = Partial<Props3>
let particalProps3: ParticalProps3 = {
  x: 1,
  y: true,
  z: 'aaaa'
}
console.log(particalProps3);
//索引查询
type kk = Props3['x' | 'y']
